package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerCarModel implements Serializable {
	private static final long serialVersionUID = 6874505L;
	
	private int id;
	private int consumerID;
	private int carType;
	private int carBrand;
	private int buyTime;
	private String buyPrice;
	private String appraisement;
	private int propertyRight;
	private int installmentTm;
	private String installmentSum;
	private String installmentBank;
	private String monthPay;
	private int cutPaymentCard;
	
	public ConsumerCarModel() {
		buyPrice = "";
		appraisement = "";
		installmentSum = "";
		monthPay = "";
		carType = -1;
		carBrand = -1;
		buyTime = -1;
		propertyRight = -1;
		installmentTm = -1;
		installmentBank = "";
		cutPaymentCard = -1;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public int getCarType() {
		return carType;
	}
	public void setCarType(int carType) {
		this.carType = carType;
	}
	public int getCarBrand() {
		return carBrand;
	}
	public void setCarBrand(int carBrand) {
		this.carBrand = carBrand;
	}
	public int getBuyTime() {
		return buyTime;
	}
	public void setBuyTime(int buyTime) {
		this.buyTime = buyTime;
	}
	
	public String getBuyPrice() {
		return buyPrice;
	}
	public void setBuyPrice(String buyPrice) {
		this.buyPrice = buyPrice;
	}

	public String getAppraisement() {
		return appraisement;
	}
	public void setAppraisement(String appraisement) {
		this.appraisement = appraisement;
	}
	public int getPropertyRight() {
		return propertyRight;
	}
	public void setPropertyRight(int propertyRight) {
		this.propertyRight = propertyRight;
	}
	public int getInstallmentTm() {
		return installmentTm;
	}
	public void setInstallmentTm(int installmentTm) {
		this.installmentTm = installmentTm;
	}
	public String getInstallmentSum() {
		return installmentSum;
	}
	public void setInstallmentSum(String installmentSum) {
		this.installmentSum = installmentSum;
	}
	public String getInstallmentBank() {
		return installmentBank;
	}
	public void setInstallmentBank(String installmentBank) {
		this.installmentBank = installmentBank;
	}
	public String getMonthPay() {
		return monthPay;
	}
	public void setMonthPay(String monthPay) {
		this.monthPay = monthPay;
	}
	public int getCutPaymentCard() {
		return cutPaymentCard;
	}
	public void setCutPaymentCard(int cutPaymentCard) {
		this.cutPaymentCard = cutPaymentCard;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("buyCarType")) {
			this.carType = jsonData.getIntValue("buyCarType");
		}
		if (jsonData.containsKey("carBrand")) {
			this.carBrand = jsonData.getIntValue("carBrand");
		}
		if (jsonData.containsKey("buyTime")) {
			this.buyTime = jsonData.getIntValue("buyTime");
		}
		if (jsonData.containsKey("buyPrice")) {
			this.buyPrice = jsonData.getString("buyPrice");
		}
		if (jsonData.containsKey("appraisePrice")) {
			this.appraisement = jsonData.getString("appraisePrice");
		}
		if (jsonData.containsKey("propertyRight")) {
			this.propertyRight = jsonData.getIntValue("propertyRight");
		}
		if (jsonData.containsKey("installmentTime")) {
			this.installmentTm = jsonData.getIntValue("installmentTime");
		}
		if (jsonData.containsKey("loanMoney")) {
			this.installmentSum = jsonData.getString("loanMoney");
		}
		if (jsonData.containsKey("installmentBank")) {
			this.installmentBank = jsonData.getString("installmentBank");
		}
		if (jsonData.containsKey("monthPay")) {
			this.monthPay = jsonData.getString("monthPay");
		}
		if (jsonData.containsKey("koukuanCard")) {
			this.cutPaymentCard = jsonData.getIntValue("koukuanCard");
		}
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (carType >= 0) {
			jsonObj.put("buyCarType", carType);
		}
		if (carBrand >= 0) {
			jsonObj.put("carBrand", carBrand);
		}
		if (buyTime >= 0) {
			jsonObj.put("buyTime", buyTime);
		}
		if (buyPrice != null && buyPrice.length() > 0) {
			jsonObj.put("buyPrice", buyPrice);
		}
		if (appraisement != null && appraisement.length() > 0) {
			jsonObj.put("appraisePrice", appraisement);
		}
		if (propertyRight >= 0) {
			jsonObj.put("propertyRight", propertyRight);
		}
		if (installmentTm >= 0) {
			jsonObj.put("installmentTime", installmentTm);
		}
		if (installmentSum != null && installmentSum.length() > 0) {
			jsonObj.put("loanMoney", installmentSum);
		}		
		if (installmentBank != null && installmentBank.length() >= 0) {
			jsonObj.put("installmentBank", installmentBank);
		}
		if (monthPay != null && monthPay.length() > 0) {
			jsonObj.put("monthPay", monthPay);
		}
		if (cutPaymentCard >= 0) {
			jsonObj.put("koukuanCard", cutPaymentCard);
		}
		
		return jsonObj;
	}

}
